# -*- coding: utf-8 -*-
import time
from selenium import webdriver
import unittest
import xlrd
from Page.loginPage import loginPage
from publicModule.login import login
from Page.noscanningPage import noscanningPage
from publicModule.noscanning import noscanning
from Page.informaintenancePage import informaintenancePage
from publicModule.informaintenance import informaintenance
from publicModule.planmaintenence import planmaintenence
class Test_PlanMaintenence(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        print('开始测试')
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(10)
        self.driver.maximize_window()
        self.driver.get("http://10.22.26.34:8080/fwd/indexlis.jsp")
        time.sleep(2)

        self.loginPage = loginPage(self.driver)
        self.login = login(self.driver)
        self.noscanningPage = noscanningPage(self.driver)
        self.noscanning = noscanning(self.driver)
        self.noscanning1 = noscanning(self.driver)
        self.noscanning2 = noscanning(self.driver)
        self.noscanning3 = noscanning(self.driver)
        self.informaintenancePage = informaintenancePage(self.driver)
        self.informaintenance = informaintenance(self.driver)
        self.planmainenence=planmaintenence(self.driver)
    # @classmethod
    # def tearDownClass(self):
    #     print('结束测试')
    #     self.driver.quit()
    def test01(self):
        print('test01')
        filename='..//TestData//loginData.xlsx'
        excel_open=xlrd.open_workbook(filename)
        table=excel_open.sheet_by_name('Sheet1')
        rows=table.nrows
        for i in range(2,rows):
            row_content=table.row_values(i)
            username=row_content[0]
            password=row_content[1]
            orgcode=row_content[2]
            login.login(self,username,password,orgcode)
    def test02(self):
        print('test02')
        noscanning.noscanning(self)
        time.sleep(2)
        noscanning.noscanning1(self)
        time.sleep(2)
        noscanning.nosanning2(self)
        time.sleep(2)
        filename = '..//TestData//test02Data.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(1, rows):
            row_content = table.row_values(i)
            policyNo = row_content[0]
            planmaintenence.plan1(self,policyNo)
    def test03(self):
            informaintenance.planDetailOpen(self)
    def test04(self):

        filename = '..//TestData//test04Data.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(1, rows):
            row_content = table.row_values(i)
            # Franchise = int(row_content[0])
            # RatePay = int(row_content[1])
            FixedAmnt = int(row_content[2])
            ExceptPrem = row_content[3]
            Remark = row_content[4]
            PlanCode=row_content[5]
            RiskCode=row_content[6]
            DutyCode = row_content[7]
            AmntType=row_content[8]
            ExceptPremType=row_content[9]
            informaintenance.informationDetail(self, FixedAmnt, ExceptPrem, Remark,PlanCode,DutyCode,RiskCode,AmntType,ExceptPremType)
    def test05(self):
        print('test05')
        informaintenance.inforDetailOver(self)

if __name__ =='__main__':
    # unittest.main()
    suite = unittest.TestLoader.loadTestsFromTestCase(Test_PlanMaintenence)
    unittest.TextTestRunner().run(suite)
